package com.heima.Controller;

import com.heima.Serivce.WemediamaterialService;
import com.heima.model.common.dtos.MaterialPagereuestDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/wemedia/MEDIA/wemedia/api/v1")
public class WemediamaterialController {

    @Autowired
    WemediamaterialService wemediamaterialService;

//    上传图片
    @PostMapping("/material/upload_picture")
    public ResponseResult UploadImg(@RequestBody MultipartFile multipartFile)
    {
        return wemediamaterialService.UpLoadImg(multipartFile);
    }

    @PostMapping("/material/list")
    public ResponseResult GetMaterialList(@RequestBody MaterialPagereuestDto materialPagereuestDto)
    {
        return wemediamaterialService.GetMaterialList(materialPagereuestDto);
    }

//    删除素材
    @GetMapping("/material/del_picture/{id}")
    public ResponseResult DelMaterial(@PathVariable Integer id)
    {
        return wemediamaterialService.DelMaterial(id);
    }

//    取消素材收藏
    @GetMapping("/material/cancel_collect/{id}")
    public ResponseResult CancelCollect(@PathVariable Integer id)
    {
        return wemediamaterialService.CancelCollect(id,(short)0 );
    }

//    收藏素材
    @GetMapping("/material/collect/{id}")
    public ResponseResult Collect(@PathVariable Integer id)
    {
        return wemediamaterialService.CancelCollect(id,(short)1 );
    }


}
